﻿namespace Borg.Framework
{
    public class MenuStrip : System.Windows.Forms.MenuStrip
    {
        internal ToolStripItemCollectionHandler tsiCollectionHandler;

        public event MenuItemEventHandler AfterHandleClick;

        public event MenuItemEventHandler BeforeHandleClick;

        public MenuStrip()
        {
            tsiCollectionHandler = new ToolStripItemCollectionHandler(Items);

            tsiCollectionHandler.BeforeHandleClick += OnBeforeHandleClick;
            tsiCollectionHandler.AfterHandleClick += OnAfterHandleClick;
        }

        protected virtual void OnAfterHandleClick(object sender, MenuItemEventArgs args)
        {
            if (AfterHandleClick != null)
                AfterHandleClick(sender, args);
        }

        protected virtual void OnBeforeHandleClick(object sender, MenuItemEventArgs args)
        {
            if (BeforeHandleClick != null)
                BeforeHandleClick(sender, args);
        }

        public virtual void RemoveActionBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemoveActionBehavior(si);
        }

        public virtual void RemoveCreateBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemoveCreateBehavior(si);
        }

        public virtual void RemoveOpenBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemoveOpenBehavior(si);
        }

        public virtual void RemovePlugBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemovePlugBehavior(si);
        }

        public virtual void RemoveRegisterBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemoveRegisterBehavior(si);
        }

        public virtual void RemoveSelectBehavior(SlotInfo si)
        {
            tsiCollectionHandler.RemoveSelectBehavior(si);
        }

        public virtual void SetActionBehavior(SlotInfo si, PlugTypeHandler itemHandler)
        {
            tsiCollectionHandler.SetActionBehavior(si, itemHandler);
        }

        public virtual void SetCreateBehavior(SlotInfo si, PlugTypeHandler itemHandler)
        {
            tsiCollectionHandler.SetCreateBehavior(si, itemHandler);
        }

        public virtual void SetOpenBehavior(SlotInfo si, string itemPath)
        {
            tsiCollectionHandler.SetOpenBehavior(si, itemPath);
        }

        public virtual void SetPlugBehavior(SlotInfo si, PlugHandler itemHandler)
        {
            tsiCollectionHandler.SetPlugBehavior(si, itemHandler);
        }

        public virtual void SetRegisterBehavior(SlotInfo si, PlugTypeHandler itemHandler)
        {
            tsiCollectionHandler.SetRegisterBehavior(si, itemHandler);
        }

        public virtual void SetSelectBehavior(SlotInfo si, PlugHandler itemHandler)
        {
            tsiCollectionHandler.SetSelectBehavior(si, itemHandler);
        }
    }
}

